from socket import *
from random import choice
import os
print("Your computer: ",gethostname())
me=socket(AF_INET,SOCK_STREAM)
me.bind((gethostname(),12345))
me.listen(2)
ag,addr=me.accept()

mhp=30
yhp=30
dice=[0,0,0,0]
cnt=[0,0,0,0]
while mhp>0 and yhp>0:
    dice[1]=choice(range(1,7))
    dice[2]=choice(range(1,7))
    dice[3]=choice(range(1,7))
    cnt[1]=1
    cnt[2]=1
    cnt[3]=3
    while True:
        print(mhp,"  ",yhp)
        print(dice[1:])
        print("1.Sword:")
        print("2.Axe:max 4")
        print("3.Roll:")
        x,y=input("input 2yh5784y3re").split(" ")
        x=int(x)
        y=int(y)
        if x==0:break
        if cnt[y]==0:continue
        if y==1:
            yhp-=dice[x]
            dice[x]=0
            cnt[y]-=1
        elif y==2:
            if dice[x]<=4:
                yhp-=dice[x]*2
                dice[x]=0
                cnt[y]-=1
            else:
                print("Nothing happened, you dazed 43uihy78rt")
        else:
            cnt[y]-=1
            dice[x]=choice(range(1,7))
    ag.send(str(yhp).encode("ASCII"))
    mhp=int(ag.recv(10))

